

#ifndef UD_DBLTRANS_H
#define UD_DBLTRANS_H 1

#include "zdbmain.h"
#include "zAdAChar.h"

#pragma pack (push, 8)

class UcDbLongTransWorkSetIterator : public UcRxObject
{
public:
    virtual ~UcDbLongTransWorkSetIterator() {};
    UCRX_DECLARE_MEMBERS(UcDbLongTransWorkSetIterator);

    virtual void           start (bool incRemovedObjs = false,
                                  bool incSecondaryObjs = false) = 0; 

    virtual bool           done () = 0;
    virtual void           step () = 0;

    virtual UcDbObjectId   objectId () const = 0;

    virtual bool           curObjectIsErased () const = 0;
    virtual bool           curObjectIsRemoved () const = 0;
    virtual bool           curObjectIsPrimary () const = 0;

};

class UcDbLongTransaction : public UcDbObject
{
public:
    UcDbLongTransaction();
    ~UcDbLongTransaction();
    UCDB_DECLARE_MEMBERS(UcDbLongTransaction);

    enum { kSameDb      = 0,
           kXrefDb      = 1,
           kUnrelatedDb = 2  };

    int                  type () const;
    UcDbObjectId         originBlock() const;
    UcDbObjectId         destinationBlock() const;

    Ucad::ErrorStatus    getLongTransactionName(ZTCHAR*&) const;

    Ucad::ErrorStatus    addToWorkSet (UcDbObjectId id);
    Ucad::ErrorStatus    removeFromWorkSet (UcDbObjectId id);
    Ucad::ErrorStatus    syncWorkSet ();

    Ucad::ErrorStatus    newWorkSetIterator(
                             UcDbLongTransWorkSetIterator*& pNewIter,
                             bool incRemovedObjs = false,
                             bool incSecondaryObjs = false) 
                                 const;

    UcDbObjectId         originObject(UcDbObjectId id) const;

    bool                 workSetHas(UcDbObjectId id, 
                                    bool bIncErased = false) const;

    UcDbIdMapping*       activeIdMap();

    void                 regenWorkSetWithDrawOrder();

    bool                 disallowDrawOrder();
};

#pragma pack (pop)

#endif
